home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / GNUChess4_0_58.lha / gnuchess-4.0 / src / new / uxdsp.c < prev    next >
C/C++ Source or Header  |  1992-08-26  |  18KB  |  897 lines

  1. /*
  2.  * uxdsp.c - ALPHA interface for CHESS
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. #include <ctype.h>
  24. #include <signal.h>
  25. #ifdef MSDOS
  26. #include <dos.h>
  27. #include <conio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <time.h>
  31.  
  32. #define ESC 0x1B
  33. #define refresh() fflush(stdout)
  34.  
  35. int mycntl1, mycntl2;
  36. static void param (short n);
  37.  
  38. #else
  39. #include <sys/param.h>
  40. #include <sys/types.h>
  41. #include <sys/file.h>
  42. #include <curses.h>
  43.  
  44. #if defined(__STDC__)
  45. /* <stdlib.h> */
  46.      extern void *malloc (size_t);
  47.      extern void exit (int);
  48.  
  49. /* <string.h> */
  50.      extern char *strcat (char *, const char *);
  51.      extern int strcmp (const char *, const char *);
  52.      extern char *strcpy (char *, const char *);
  53.  
  54. /* <time.h> */
  55.      extern long int time (long int *);
  56. #endif
  57.  
  58. #endif /* MSDOS */
  59.  
  60. #include "gnuchess.h"
  61.  
  62. extern short int pscore[2];
  63.  
  64. #define TAB (46)
  65. #define VIR_C(s)  ((flag.reverse) ? 7-column(s) : column(s))
  66. #define VIR_R(s)  ((flag.reverse) ? 7-row(s) : row(s))
  67.  
  68. unsigned short int MV[MAXDEPTH];
  69. int MSCORE;
  70. char *DRAW;
  71. extern char mvstr[4][6];
  72.  
  73. extern char *getenv (const char *);
  74. void TerminateSearch (int), Die (int);
  75.  
  76. void
  77. Initialize (void)
  78. {
  79.   signal (SIGINT, Die);
  80. #ifndef MSDOS
  81.   signal (SIGQUIT, Die);
  82.   initscr ();
  83.   crmode ();
  84. #else
  85.   mycntl1 = mycntl2 = 0;
  86. #endif /* MSDOS */
  87. }
  88.  
  89. void
  90. ExitChess (void)
  91. {
  92.   ListGame ();
  93.   gotoXY (1, 24);
  94. #ifndef MSDOS
  95.   refresh();
  96.   nocrmode ();
  97.   endwin ();
  98. #endif /* MSDOS */
  99.   exit (0);
  100. }
  101.  
  102. void
  103. Die (int Sig)
  104. {
  105.   char s[80];
  106.  
  107.   signal (SIGINT, SIG_IGN);
  108. #ifdef MSDOS
  109.   Sig++;            /* shut up the compiler */
  110. #else
  111.   signal (SIGQUIT, SIG_IGN);
  112. #endif /* MSDOS */
  113.   ShowMessage (CP[31]);        /*Abort?*/
  114.   scanz ("%s", s);
  115.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  116.     ExitChess ();
  117.   signal (SIGINT, Die);
  118. #ifndef MSDOS
  119.   signal (SIGQUIT, Die);
  120. #endif /* MSDOS */
  121. }
  122.  
  123. void
  124. TerminateSearch (int Sig)
  125. {
  126.   signal (SIGINT, SIG_IGN);
  127. #ifdef MSDOS
  128.   Sig++;            /* shut up the compiler */
  129. #else
  130.   signal (SIGQUIT, SIG_IGN);
  131. #endif /* MSDOS */
  132.   if (!flag.timeout)
  133.     flag.musttimeout = true;
  134.   flag.bothsides = false;
  135.   signal (SIGINT, Die);
  136. #ifndef MSDOS
  137.   signal (SIGQUIT, Die);
  138. #endif /* MSDOS */
  139. }
  140. void
  141. ShowLine (short unsigned int *bstline)
  142. {
  143. }
  144.  
  145. void
  146. help (void)
  147. {
  148.   ClrScreen ();
  149.   /*printz ("CHESS command summary\n");*/
  150.   printz (CP[40]);
  151.   printz ("----------------------------------------------------------------\n");
  152.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  153.   printz (CP[158]);
  154.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  155.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  156.   /*printz ("a7a8q     promote pawn to queen\n");*/
  157.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  158.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  159.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  160.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  161.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  162.   /*printz ("bd        redraw board            reverse   board display\n");*/
  163.   printz (CP[130]);
  164.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", book
  165. count, BOOKSIZE);*/
  166.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  167.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  168.   printz (CP[200]);
  169.   /*printz ("edit      edit board              force     enter game moves\n");*/
  170.   printz (CP[153]);
  171.   /*printz ("switch    sides with computer     both      computer match\n");*/
  172.   printz (CP[194]);
  173.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  174.   printz (CP[202]);
  175.   /*printz ("depth     set search depth        clock     set time control\n");*/
  176.   printz (CP[149]);
  177.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" :
  178. "on");*/
  179.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  180.   /*printz ("save      game to file            get       game from file\n");*/
  181.   printz (CP[188]);
  182.   /*printz ("random    randomize play          new       start new game\n");*/
  183.   printz (CP[181]);
  184.   gotoXY (10, 20);
  185.   printz (CP[47], ColorStr[computer]);
  186.   gotoXY (10, 21);
  187.   printz (CP[97], ColorStr[opponent]);
  188.   gotoXY (10, 22);
  189.   printz (CP[79], MaxResponseTime/100);
  190.   gotoXY (10, 23);
  191.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  192.   gotoXY (40, 20);
  193.   printz (CP[52], MaxSearchDepth);
  194.   gotoXY (40, 21);
  195.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  196.   gotoXY (40, 22);
  197.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  198.   gotoXY (40, 23);
  199.   printz (CP[73]);
  200.   gotoXY (10, 24);
  201.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  202.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  203.   refresh ();
  204. #ifdef BOGUS
  205.   fflush (stdin); /*what is this supposed to do??*/
  206. #endif /*BOGUS*/
  207.   getchar ();
  208.   ClrScreen ();
  209.   UpdateDisplay (0, 0, 1, 0);
  210. }
  211.  
  212.  
  213. void
  214. EditBoard (void)
  215.  
  216. /*
  217.  * Set up a board position. Pieces are entered by typing the piece followed
  218.  * by the location. For example, Nf3 will place a knight on square f3.
  219.  */
  220.  
  221. {
  222.   short a, r, c, sq, i;
  223.   char s[80];
  224.  
  225.   flag.regularstart = false;
  226.   Book = false;
  227.   ClrScreen ();
  228.   UpdateDisplay (0, 0, 1, 0);
  229.   gotoXY (TAB, 3);
  230.   printz (CP[29]);
  231.   gotoXY (TAB, 4);
  232.   printz (CP[28]);
  233.   gotoXY (TAB, 5);
  234.   printz (CP[136]);
  235.   gotoXY (TAB, 7);
  236.   printz (CP[64]);
  237.   a = white;
  238.   do
  239.     {
  240.       gotoXY (TAB, 6);
  241.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  242.       gotoXY (TAB + 24, 7);
  243.       ClrEoln ();
  244.       scanz ("%s", s);
  245.       if (s[0] == CP[28][0])    /*#*/
  246.     {
  247.       for (sq = 0; sq < 64; sq++)
  248.         {
  249.           board[sq] = no_piece;
  250.           color[sq] = neutral;
  251.           DrawPiece (sq);
  252.         }
  253.     }
  254.       if (s[0] == CP[136][0])    /*c*/
  255.     a = otherside[a];
  256.       c = s[1] - 'a';
  257.       r = s[2] - '1';
  258.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  259.     {
  260.       sq = locn (r, c);
  261.       for (i = king; i > no_piece; i--)
  262.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  263.           break;
  264.       board[sq] = i;
  265.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  266.       DrawPiece (sq);
  267.     }
  268.   } while (s[0] != CP[29][0]);    /*.*/
  269.  
  270.   for (sq = 0; sq < 64; sq++)
  271.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  272.   GameCnt = 0;
  273.   Game50 = 1;
  274.   ZeroRPT ();
  275.   Sdepth = 0;
  276.   InitializeStats ();
  277.   ClrScreen ();
  278.   UpdateDisplay (0, 0, 1, 0);
  279. }
  280.  
  281. void
  282. ShowPlayers (void)
  283. {
  284.   gotoXY (5, ((flag.reverse) ? 23 : 2));
  285.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  286.   gotoXY (5, ((flag.reverse) ? 2 : 23));
  287.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  288. }
  289.  
  290. void
  291. ShowDepth (char ch)
  292. {
  293.   gotoXY (TAB, 4);
  294.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  295.   ClrEoln ();
  296. }
  297.  
  298. void
  299. ShowScore (short score)
  300. {
  301.   gotoXY (TAB, 5);
  302.   printz (CP[104], score);
  303.   ClrEoln ();
  304. }
  305.  
  306. void
  307. ShowMessage (char *s)
  308. {
  309.   gotoXY (TAB, 6);
  310.   printz ("%s", s);
  311.   ClrEoln ();
  312. }
  313.  
  314. void
  315. ClearMessage (void)
  316. {
  317.   gotoXY (TAB, 6);
  318.   ClrEoln ();
  319. }
  320.  
  321. void
  322. ShowCurrentMove (short int pnt, short int f, short int t)
  323. {
  324.   algbr (f, t, false);
  325.   gotoXY (TAB, 7);
  326.   printz ("(%2d) %4s", pnt, mvstr[0]);
  327. }
  328.  
  329. void
  330. ShowHeader (void)
  331. {
  332.   gotoXY (TAB, 2);
  333.   printz (CP[69]);
  334. }
  335.  
  336. void
  337. ShowSidetoMove (void)
  338. {
  339.   gotoXY (TAB, 14);
  340.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  341.   ClrEoln ();
  342. }
  343.  
  344. void
  345. ShowPrompt (void)
  346. {
  347.   gotoXY (TAB, 19);
  348.   printz (CP[121]);        /*Your movwe is?*/
  349.   ClrEoln ();
  350. }
  351.  
  352. void
  353. ShowNodeCnt (long int NodeCnt)
  354. {
  355.   gotoXY (TAB, 21);
  356.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  357.   ClrEoln ();
  358. }
  359.  
  360. void
  361. ShowResults (short int score, short unsigned int *bstline, char ch)
  362. {
  363.   unsigned char d, ply;
  364.  
  365.   if (flag.post)
  366.     {
  367.       ShowDepth (ch);
  368.       ShowScore (score);
  369.       d = 7;
  370.       for (ply = 1; bstline[ply] > 0; ply++)
  371.     {
  372.       if (ply % 4 == 1)
  373.         {
  374.           gotoXY (TAB, ++d);
  375.           ClrEoln ();
  376.         }
  377.       algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
  378.       printz ("%5s ", mvstr[0]);
  379.     }
  380.       ClrEoln ();
  381.       while (d < 13)
  382.     {
  383.       gotoXY (TAB, ++d);
  384.       ClrEoln ();
  385.     }
  386.     }
  387. }
  388.  
  389. void
  390. SearchStartStuff (short int side)
  391. {
  392.   short i;
  393.  
  394.   signal (SIGINT, TerminateSearch);
  395. #ifdef MSDOS
  396.   side++;            /* shut up the compiler */
  397. #else
  398.   signal (SIGQUIT, TerminateSearch);
  399. #endif /* MSDOS */
  400.   for (i = 4; i < 14; i++)
  401.     {
  402.       gotoXY (TAB, i);
  403.       ClrEoln ();
  404.     }
  405. }
  406.  
  407. void
  408. OutputMove (void)
  409. {
  410.   int i;
  411.  
  412.   UpdateDisplay (rootnode.f, rootnode.t, 0, (short) rootnode.flags);
  413.   gotoXY (TAB, 17);
  414.   if(flag.illegal){printz(CP[225]);return;}
  415.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  416.   if (flag.beep)
  417.     putchar (7);
  418.   ClrEoln ();
  419.  
  420.   gotoXY (TAB, 24);
  421.   if (rootnode.flags & draw)
  422.     printz (CP[58]);
  423.   else if (rootnode.score == -9999)
  424.     printz (CP[95]);
  425.   else if (rootnode.score == 9998)
  426.     printz (CP[44]);
  427. #ifdef VERYBUGGY
  428.   else if (rootnode.score < -9000)
  429.     printz (CP[96]);
  430.   else if (rootnode.score > 9000)
  431.     printz (CP[45]);
  432. #endif /*VERYBUGGY*/
  433.   ClrEoln ();
  434.   if (flag.post)
  435.     {
  436.       register short h, l, t;
  437.  
  438.       h = TREE;
  439.       l = 0;
  440.       t = TREE >> 1;
  441.       while (l != t)
  442.     {
  443.       if (Tree[t].f || Tree[t].t)
  444.         l = t;
  445.       else
  446.         h = t;
  447.       t = (l + h) >> 1;
  448.     }
  449.  
  450.       ShowNodeCnt (NodeCnt);
  451.       gotoXY (TAB, 22);
  452.       printz (CP[81], t);    /*Max Tree=*/
  453.       ClrEoln ();
  454.     }
  455.   ShowSidetoMove ();
  456. }
  457.  
  458. void
  459. UpdateClocks (void)
  460. {
  461.   short m, s;
  462.  
  463.   m = (short) (et / 6000);
  464.   s = (short) (et - 6000 * (long) m) / 100;
  465.   if (TCflag)
  466.     {
  467.       m = (short) ((TimeControl.clock[player] - et) / 6000);
  468.       s = (short) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  469.     }
  470.   if (m < 0)
  471.     m = 0;
  472.   if (s < 0)
  473.     s = 0;
  474.   if (player == white)
  475.     gotoXY (20, (flag.reverse) ? 2 : 23);
  476.   else
  477.     gotoXY (20, (flag.reverse) ? 23 : 2);
  478.   printz ("%d:%02d   ", m, s);
  479.   if (flag.post)
  480.     ShowNodeCnt (NodeCnt);
  481.   refresh ();
  482. }
  483.  
  484. void
  485. gotoXY (short int x, short int y)
  486. {
  487. #ifdef MSDOS
  488.   putchar (ESC);
  489.   putchar ('[');
  490.   param (y);
  491.   putchar (';');
  492.   param (x);
  493.   putchar ('H');
  494. #else
  495.   move (y - 1, x - 1);
  496. #endif /* MSDOS */
  497. }
  498.  
  499. void
  500. ClrScreen (void)
  501. {
  502. #ifdef MSDOS
  503.   putchar (ESC);
  504.   putchar ('[');
  505.   putchar ('2');
  506.   putchar ('J');
  507. #else
  508.   clear ();
  509. #endif /* MSDOS */
  510.   refresh ();
  511. }
  512.  
  513. void
  514. ClrEoln (void)
  515. {
  516. #ifdef MSDOS
  517.   putchar (ESC);
  518.   putchar ('[');
  519.   putchar ('K');
  520. #else
  521.   clrtoeol ();
  522. #endif /* MSDOS */
  523.   refresh ();
  524. }
  525.  
  526. #ifdef MSDOS
  527. void
  528. param (short n)
  529. {
  530.   if (n >= 10)
  531.     {
  532.       register short d, q;
  533.  
  534.       q = n / 10;
  535.       d = n % 10;
  536.       putchar (q + '0');
  537.       putchar (d + '0');
  538.     }
  539.   else
  540.     putchar (n + '0');
  541. }
  542.  
  543. #endif /* MSDOS */
  544.  
  545. void
  546. DrawPiece (short int sq)
  547. {
  548.   register char x;
  549.  
  550.   if (color[sq] == black)
  551. #if defined(MSDOS) && !defined(SEVENBIT)
  552.     x = '7';            /* print WHITE boldface, */
  553.   else
  554.     x = '1';            /* print BLACK inverted     */
  555.   gotoXY (6 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  556.   printz ("\033[%cm%c\033[0m", x, pxx[board[sq]]);
  557. #else
  558.     x = '*';
  559.   else
  560.     x = ' ';
  561.   gotoXY (5 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  562.   printz ("%c%c ", x, pxx[board[sq]]);
  563. #endif /* MSDOS && !SEVENBIT */
  564. }
  565.  
  566. void
  567. ShowPostnValue (short int sq)
  568.  
  569. /*
  570.  * must have called ExaminePosition() first
  571.  */
  572.  
  573. {
  574.   short score;
  575.  
  576.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  577.   score = ScorePosition (color[sq]);
  578.   if (color[sq] != neutral)
  579.     printz ("%3d ", svalue[sq]);
  580.   else
  581.     printz ("   ");
  582. }
  583.  
  584. void
  585. ShowPostnValues (void)
  586. {
  587.   short sq, score;
  588.  
  589.   ExaminePosition ();
  590.   for (sq = 0; sq < 64; sq++)
  591.     ShowPostnValue (sq);
  592.   score = ScorePosition (opponent);
  593.   gotoXY (TAB, 5);
  594.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  595.  
  596.   ClrEoln ();
  597. }
  598.  
  599. void
  600. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  601. {
  602.   short i, sq, z;
  603.  
  604.   if (redraw)
  605.     {
  606.       ShowHeader ();
  607.       ShowPlayers ();
  608.  
  609.       i = 3;
  610.       gotoXY (3, ++i);
  611. #if defined(MSDOS) && !defined(SEVENBIT)
  612.       printz ("\332\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  613.         "\302\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  614.           "\302\304\304\304\304\302\304\304\304\304\277");
  615. #else
  616.       printz ("+----+----+----+----+----+----+----+----+");
  617. #endif /* MSDOS && !SEVENBIT */
  618.       while (i < 19)
  619.     {
  620.       gotoXY (1, ++i);
  621.       if (flag.reverse)
  622.         z = (i / 2) - 1;
  623.       else
  624.         z = 10 - (i / 2);
  625. #if defined(MSDOS) && !defined(SEVENBIT)
  626.       printz ("%d \263    \263    \263    \263    \263    \263    " \
  627.           "\263    \263    \263", z);
  628. #else
  629.       printz ("%d |    |    |    |    |    |    |    |    |", z);
  630. #endif /* MSDOS && !SEVENBIT */
  631.       gotoXY (3, ++i);
  632.       if (i < 19)
  633. #if defined(MSDOS) && !defined(SEVENBIT)
  634.         printz ("\303\304\304\304\304\305\304\304\304\304\305\304\304" \
  635.             "\304\304\305\304\304\304\304\305\304\304\304\304\305" \
  636.             "\304\304\304\304\305\304\304\304\304\305\304\304\304" \
  637.             "\304\264");
  638. #else
  639.         printz ("+----+----+----+----+----+----+----+----+");
  640. #endif /* MSDOS && !SEVENBIT */
  641.     }
  642. #if defined(MSDOS) && !defined(SEVENBIT)
  643.       printz ("\300\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  644.         "\301\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  645.           "\301\304\304\304\304\301\304\304\304\304\331");
  646. #else
  647.       printz ("+----+----+----+----+----+----+----+----+");
  648. #endif /* MSDOS && !SEVENBIT */
  649.       gotoXY (3, 21);
  650.       if (flag.reverse)
  651.     printz (CP[16]);
  652.       else
  653.     printz (CP[15]);
  654.       for (sq = 0; sq < 64; sq++)
  655.     DrawPiece (sq);
  656.     }
  657.   else
  658.     {
  659.       DrawPiece (f);
  660.       DrawPiece (t);
  661.       if (isspec & cstlmask)
  662.     if (t > f)
  663.       {
  664.         DrawPiece (f + 3);
  665.         DrawPiece (t - 1);
  666.       }
  667.     else
  668.       {
  669.         DrawPiece (f - 4);
  670.         DrawPiece (t + 1);
  671.       }
  672.       else if (isspec & epmask)
  673.     {
  674.       DrawPiece (t - 8);
  675.       DrawPiece (t + 8);
  676.     }
  677.     }
  678.   refresh ();
  679. }
  680.  
  681. extern char *InPtr;
  682. void
  683. skip ()
  684. {
  685.   while (*InPtr != ' ')
  686.     InPtr++;
  687.   while (*InPtr == ' ')
  688.     InPtr++;
  689. }
  690. void
  691. skipb ()
  692. {
  693.   while (*InPtr == ' ')
  694.     InPtr++;
  695. }
  696.  
  697. void
  698. ChangeAlphaWindow (void)
  699. {
  700.   ShowMessage (CP[114]);
  701.   scanz ("%hd", &WAwindow);
  702.   ShowMessage (CP[34]);
  703.   scanz ("%hd", &BAwindow);
  704. }
  705.  
  706. void
  707. ChangeBetaWindow (void)
  708. {
  709.   ShowMessage (CP[115]);
  710.   scanz ("%hd", &WBwindow);
  711.   ShowMessage (CP[35]);
  712.   scanz ("%hd", &BBwindow);
  713. }
  714.  
  715. void
  716. GiveHint (void)
  717. {
  718.   char s[40];
  719.   if (hint)
  720.     {
  721.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  722.       strcpy (s, CP[198]);    /*try*/
  723.       strcat (s, mvstr[0]);
  724.       ShowMessage (s);
  725.     }
  726.   else
  727.     ShowMessage (CP[223]);
  728. }
  729.  
  730. void
  731. ChangeHashDepth (void)
  732. {
  733.   ShowMessage (CP[163]);
  734.   scanz ("%hd", &HashDepth);
  735.   ShowMessage (CP[82]);
  736.   scanz ("%hd", &HashMoveLimit);
  737. }
  738.  
  739. void
  740. ChangeSearchDepth (void)
  741. {
  742.   ShowMessage (CP[150]);
  743.   scanz ("%hd", &MaxSearchDepth);
  744.   TCflag = !(MaxSearchDepth > 0);
  745. }
  746.  
  747. void
  748. SetContempt (void)
  749. {
  750.   ShowMessage (CP[142]);
  751.   scanz ("%hd", &contempt);
  752. }
  753.  
  754. void
  755. ChangeXwindow (void)
  756. {
  757.   ShowMessage (CP[208]);
  758.   scanz ("%hd", &xwndw);
  759. }
  760.  
  761. void
  762. SelectLevel (void)
  763. {
  764.   int item;
  765.  
  766.   ClrScreen ();
  767.   gotoXY (32, 2);
  768.   printz (CP[41]);
  769.   gotoXY (20, 4);
  770.   printz (CP[18]);
  771.   gotoXY (20, 5);
  772.   printz (CP[19]);
  773.   gotoXY (20, 6);
  774.   printz (CP[20]);
  775.   gotoXY (20, 7);
  776.   printz (CP[21]);
  777.   gotoXY (20, 8);
  778.   printz (CP[22]);
  779.   gotoXY (20, 9);
  780.   printz (CP[23]);
  781.   gotoXY (20, 10);
  782.   printz (CP[24]);
  783.   gotoXY (20, 11);
  784.   printz (CP[25]);
  785.   gotoXY (20, 12);
  786.   printz (CP[26]);
  787.   gotoXY (20, 13);
  788.   printz (CP[27]);
  789.  
  790.   OperatorTime = 0;
  791.   TCmoves = 60;
  792.   TCminutes = 5;
  793.   TCseconds = 0;
  794.  
  795.   gotoXY (20, 17);
  796.   printz (CP[62]);
  797.   refresh ();
  798.   scanz ("%d", &item);
  799.   switch (item)
  800.     {
  801.     case 1:
  802.       TCmoves = 60;
  803.       TCminutes = 5;
  804.       break;
  805.     case 2:
  806.       TCmoves = 60;
  807.       TCminutes = 15;
  808.       break;
  809.     case 3:
  810.       TCmoves = 60;
  811.       TCminutes = 30;
  812.       break;
  813.     case 4:
  814.       TCmoves = 40;
  815.       TCminutes = 30;
  816.       break;
  817.     case 5:
  818.       TCmoves = 40;
  819.       TCminutes = 60;
  820.       break;
  821.     case 6:
  822.       TCmoves = 40;
  823.       TCminutes = 120;
  824.       break;
  825.     case 7:
  826.       TCmoves = 40;
  827.       TCminutes = 240;
  828.       break;
  829.     case 8:
  830.       TCmoves = 1;
  831.       TCminutes = 15;
  832.       break;
  833.     case 9:
  834.       TCmoves = 1;
  835.       TCminutes = 60;
  836.       break;
  837.     case 10:
  838.       TCmoves = 1;
  839.       TCminutes = 600;
  840.       break;
  841.     }
  842.  
  843.   TCflag = (TCmoves > 0);
  844.   SetTimeControl ();
  845.   ClrScreen ();
  846.   UpdateDisplay (0, 0, 1, 0);
  847. }
  848.  
  849. void
  850. DoDebug (void)
  851. {
  852.   short c, p, sq, tp, tc, tsq, score;
  853.   char s[40];
  854.  
  855.   ExaminePosition ();
  856.   ShowMessage (CP[65]);
  857.   scanz ("%s", s);
  858.   c = neutral;
  859.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /* w W*/
  860.     c = white;
  861.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*b B*/
  862.     c = black;
  863.   for (p = king; p > no_piece; p--)
  864.     if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
  865.       break;
  866.   for (sq = 0; sq < 64; sq++)
  867.     {
  868.       tp = board[sq];
  869.       tc = color[sq];
  870.       board[sq] = p;
  871.       color[sq] = c;
  872.       tsq = PieceList[c][1];
  873.       PieceList[c][1] = sq;
  874.       ShowPostnValue (sq);
  875.       PieceList[c][1] = tsq;
  876.       board[sq] = tp;
  877.       color[sq] = tc;
  878.     }
  879.   score = ScorePosition (opponent);
  880.   gotoXY (TAB, 5);
  881.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  882.  
  883.   ClrEoln ();
  884. }
  885. void
  886. DoTable (short table[64])
  887. {
  888.   short  sq;
  889.   ExaminePosition ();
  890.   for (sq=0;sq<64;sq++){
  891.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  892.   printz ("%3d ", table[sq]);
  893.  
  894. }
  895. }
  896.  
  897.